package com.example.mapper.aboutUser;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.vo.response.SystemPermissionDTO;
import com.example.pojo.aboutUser.UserPermissionRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserPermissionRelationMapper extends BaseMapper<UserPermissionRelation> {

    // 根据用户id，查询出用户所有的权限
    @Select("SELECT p.* FROM user u JOIN user_permission_relation up ON u.id = up.user_id " +
            "JOIN system_permission p ON up.permission_id = p.id WHERE u.id = #{userId} and p.permission_state = true and p.is_delete = false")
    List<SystemPermissionDTO> getPermissionsByUserId(Integer userId);
}
